using System;
using System.Collections.Generic;
using System.Text;
using IGGCore;

namespace IGG
{
    /// <summary>
    /// The lineup formatter for the console app
    /// </summary>
    public class ModeLineupFormatter : IModeFormatter
    {
        #region IModeFormatter Members

        /// <summary>
        /// Format the two teams lineup for the console app
        /// </summary>
        public void FormatMode(Scoreboard board)
        {
            Game game = board.SelectedGame;
            Console.WriteLine(" LINEUPS:");
            Console.WriteLine();
            if (game.AwayTeam.Lineup[0] == null)
            {
                Console.WriteLine(" Information unavailable. Try later.");
            }
            else
            {
                Console.Write(" " + ToolBox.GetFormattedStringPadRight(game.AwayTeam.City, 25));
                Console.WriteLine(game.HomeTeam.City);

                Console.WriteLine();
                for (int i = 0; i < 9; i++)
                {
                    Console.Write(" " + ToolBox.GetFormattedStringPadRight((i + 1) + ": "
                        + game.AwayTeam.Lineup[i].PartialName, 25));
                    Console.WriteLine((i + 1) + ": " + game.HomeTeam.Lineup[i].PartialName);
                }
                Console.WriteLine();

                if (game.AwayTeam.Lineup[9] != null)
                {
                    Console.Write(" " + ToolBox.GetFormattedStringPadRight("P: "
                        + game.AwayTeam.Lineup[9].PartialName, 25));
                }
                else
                {
                    Console.Write(" " + ToolBox.GetFormattedStringPadRight("P: "+ "Unknown", 25));
                }
                if (game.HomeTeam.Lineup[9] != null)
                {
                    Console.WriteLine("P: " + game.HomeTeam.Lineup[9].PartialName);
                }
                else
                {
                    Console.WriteLine("P: Unknown");
                }
            }
        }

        #endregion
    }
}
